﻿@model IEnumerable<Scrumrun.Models.Project>

@{
    ViewBag.Title = "Projects";
}

@helper Truncate(string input, int length)
{
     if (input.Length <= length) {
          @input
     } else {
          @input.Substring(0, length)<text>...</text>
     }
} 


<h3>Projects</h3>

<div class="row mainwrapper">
    <div class="span2">

        <p>
            @if(User.IsInRole("Admin")){
                @Html.ActionLink("New Project", "Create", null, new { @class ="btn btn-success"})
            }else{
                <div class="alert alert-success"><button type="button" class="close" data-dismiss="alert">&times;</button>
                Only Admin can create new projects. Please contact admin if you want to create new project.
                </div>                
            }
        </p>



    </div>

    <div class="span10">
        <div class="contentwrap">

            <h4>Select project</h4>


            <table class="srtable">
                <tr>
                    <th>
                        @Html.DisplayNameFor(model => model.Name)
                    </th>
                    <th>
                        @Html.DisplayNameFor(model => model.StartDate)
                    </th>
                    <th>
                        @Html.DisplayNameFor(model => model.EndDate)
                    </th>
                                @if(User.IsInRole("Admin")){
                    <th></th>
                                }
                </tr>

                @foreach (var item in Model)
                {
                    <tr>
                        <td>
                            @*@Html.DisplayFor(modelItem => item.Name)*@
                            @Html.ActionLink(item.Name,"Details", "Project", new { id=item.ProjectId },null)
                            @*@Truncate(item.Name, 50);*@
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.StartDate)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.EndDate)
                        </td>
                         @if(User.IsInRole("Admin")){
                        <td>
                            @Html.ActionLink("Edit", "Edit", new { id = item.ProjectId }) |
            @Html.ActionLink("Delete", "Delete", new { id = item.ProjectId })
                        </td>
                         }
                    </tr>
                }

            </table>

            <br />
            <h4><i class="icon-tasks"></i>Today's Tasks</h4>
             @Html.Action("TodaysTasks")
            <!--tasks-->

        </div>
    </div>
</div>

@section Scripts {
   
}